﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入第一个操作数:");
            double a = Double.Parse(Console.ReadLine());
            Console.Write("请输入第二个操作数:");
            double b = Double.Parse(Console.ReadLine());
            Console.Write("请输入想要进行的运算:");
            char c = Char.Parse(Console.ReadLine());
            double result;
            switch (c)
            {
                case '+':
                    {
                        result = a + b;
                        Console.WriteLine($"计算结果为{result}");
                        break;
                    }
                case '-':
                    {
                        result = a - b;
                        Console.WriteLine($"计算结果为{result}");
                        break;
                    }
                case '*':
                    {
                        result = a * b;
                        Console.WriteLine($"计算结果为{result}");
                        break;
                    }
                case '/':
                    {
                        if (b == 0)
                        {
                            Console.WriteLine("非法除零操作");
                            break;
                        }
                        result = a / b;
                        Console.WriteLine($"计算结果为{result}");
                        break;
                    }
                default:
                    {
                        Console.WriteLine("运算符错误");
                        break;
                    }
            }
            Console.ReadKey();
        }
    }
}
